import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'; //引入elementPlus图标
import VueWechatTitle from 'vue-wechat-title'; //统一标题
import {debounce} from 'lodash' //防抖函数

// 解决 ResizeObserver 循环更新导致的报错问题
// 全局捕获 ResizeObserver 的错误
// Element Plus 3.2.0 版本及以上已经内置了对 ResizeObserver 的处理
const resizeObserver =  (window).ResizeObserver;
(window).ResizeObserver = class ResizeObserver extends resizeObserver {
    constructor(callback) {
        callback = debounce(callback, 100); // 使用 lodash 的 debounce 方法进行防抖处理
        super(callback);
    }
}
//全局防抖↑↑↑↑

const app = createApp(App)
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
}


app.use(store).use(router).use(ElementPlus).use(VueWechatTitle).mount('#app')
